import { UserAction } from "@/types/store"
import { User, UserInfo } from "@/types/data"
type UserState = {
    user: User,
    userinfo: UserInfo
}
const inititalState: UserState = {
    user: {},
    userinfo: {}
} as UserState  // 类型断言
export default function profile (state = inititalState, action: UserAction) {
    switch (action.type) {
        case "user/profile":
        return { ...state, user: action.payload }
        case "user/userinfo":
        return { ...state, userinfo: action.payload }
        case "user/updateProfile":
        return { ...state, userinfo:  { ...state.userinfo, ...action.payload }}
        default:
           return state
    }

}